﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Contoso.Workflow.LocalService;
using Contoso.Workflow.Management;
using Contoso.Workflow.Model;

public partial class UserControl_ExpenseForm : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        showForm();
    }

    private void hideForm()
    {
        ExpenseFormPMCheck1.IsUse = false;
        ExpenseFormGMCheck1.IsUse = false;
        ExpenseFormRequestCheck1.IsUse = false;
        ExpenseFormAccountantPayment1.IsUse = false;
        ExpenseFormPMCheck1.Visible = false;
        ExpenseFormGMCheck1.Visible = false;
        ExpenseFormRequestCheck1.Visible = false;
        ExpenseFormAccountantPayment1.Visible = false;
    }

    private void showForm()
    {
        hideForm();
        
        //获得当前流程状态
        WorkItemMgr workItemMgr = new WorkItemMgr();
        string instaceState = workItemMgr.GetInstanceStateByInstanceId(expenseData.InstanceID);
        //根据当前状态显示表单
        if (instaceState == "PMCheckState")
        {
            ExpenseFormPMCheck1.IsUse = true;
            ExpenseFormPMCheck1.Visible = true;
            ExpenseFormPMCheck1.UCExpenseData = expenseData;
        }
        else if (instaceState == "GMCheckState")
        {
            ExpenseFormGMCheck1.IsUse = true;
            ExpenseFormGMCheck1.Visible = true;
            ExpenseFormGMCheck1.UCExpenseData = expenseData;
        }
        else if (instaceState == "RequestState")
        {
            ExpenseFormRequestCheck1.IsUse = true;
            ExpenseFormRequestCheck1.Visible = true;
            ExpenseFormRequestCheck1.UCExpenseData = expenseData;
        }
        else if (instaceState == "AccountantPaymentState")
        {
            ExpenseFormAccountantPayment1.IsUse = true;
            ExpenseFormAccountantPayment1.Visible = true;
            ExpenseFormAccountantPayment1.UCExpenseData = expenseData;
        }

        
}

    private ExpenseData expenseData;
    public ExpenseData UCExpenseData
    {
        get { return expenseData; }
        set { expenseData = value; }
    }
}
